#pragma once
//common inlines

#ifndef glib_operations_h
template<class T>
inline T sqr(T x) { return x*x; }
#endif

template<class T>
inline double Euclidean(T x, T y)
	{ return sqrt(sqr(x) + sqr(y)); }

template<class T>
inline T limit( T val, T mn, T mx ) { 
	return (val < mn) ? mn : ((val > mx) ? mx : val);
}

///swap for simple types
template<class T>
inline void simple_swap( T &x, T &y ) {
	T t(x);
	x = y;
	y = t;
}

//is the number not a number?
template <class T>
inline bool isNaN( T x ) {
	const T nan = std::numeric_limits<T>::quiet_NaN();
	return memcmp( &x, &nan, sizeof(T) ) == 0;
}

